package com.flysky.common;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

import com.flysky.model.user.UserHbmModel;

@Aspect
public class AuthorityMananger {

	//authority monitor
	@Pointcut(value="execution(* com.flysky.controller.finance.FinanceController.*(javax.servlet.http.HttpServletRequest,..)) && args(param,*)")
	public void userActionPointCut(HttpServletRequest param) {}
	
	@Before(value="userActionPointCut(param)", argNames="param")
	public void userAuthorityMonitor(JoinPoint joinPoint,HttpServletRequest param) throws UserUnLoginException{
		HttpSession session = param.getSession();
		UserHbmModel userModel =(UserHbmModel)session.getAttribute("user");
		if(null == userModel){
			throw new UserUnLoginException("User doesn't login!");
		}
	}
}
